const Payment = require('wxpay-v3');

const WXPAY3 = new Payment({
  appid: 'wxfb633c75dc609440',
  mchid: '1617230410',
  private_key: require('fs').readFileSync('/Users/eden/Desktop/panleV3/API/lib/wxPay/apiclient_key.pem').toString(),//或者直接复制证书文件内容
  serial_no: '38329D64F43D4AEF1956995F6727F8F1F53C1023',
  apiv3_private_key: 'Shi12345Liu12345Hong1234Le123456',
  notify_url: 'https://weixin.qq.com/',
})
/**
 * #### 通用请求
 * @param {JSON} body 
 */
const JSAPIV3 = async (body) => {
  // let result = await WXPAY3.jsapi({
  //   description: '测试支付-熊猫公仔',
  //   out_trade_no: Date.now().toString(),
  //   amount: {
  //     total: 1
  //   },
  //   payer: {
  //     openid: 'o0Md_5Dbghi-wFW4U5mb984qcTHw'
  //   },

  // })
  // console.log(result)
  // return result

  let result = await WXPAY3.native({
      description:'测试支付-熊猫公仔',
      out_trade_no:Date.now().toString(),
      amount:{
          total:1
      }
  })
  console.log(result)
  return result
}

module.exports = {
  JSAPIV3
};